import dayjs from 'dayjs';
import { downLoad, request } from '../../../request';
export function wipPlanprocess() {
  return request({
    url: `/qms/agv/plan/wipPlan/process`,
    method: 'get'
  });
}
export function systemoperloglist(params: any) {
  return request({
    url: `/system/operlog/list`,
    method: 'get',
    params
  });
}
export function systemlogininforlist(params: any) {
  return request({
    url: `/system/logininfor/list`,
    method: 'get',
    params
  });
}
export function planplatinglist(params: any) {
  return request({
    url: `/rcerp/agv/plan/plating/list`,
    method: 'get',
    params
  });
}

export function exportFinishedGoodsDelivery(params: any) {
  return downLoad({
    url: ``,
    method: 'get',
    params,
    fileName: `成品仓出货导出${dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`
  });
}

export function getPlanHeader(params: any) {
  return request({
    url: `/mes/plan/monthlyCapacityTarget/month`,
    method: 'get',
    params
  });
}

export function getPlanList(params: any) {
  return request({
    url: `/mes/plan/monthlyCapacityTarget/list`,
    method: 'get',
    params
  });
}

// 月计划产能目标维护
export function monthPlanCapacityTarget(params: any) {
  return Promise.all([getPlanHeader({ startDate: params.startDate }), getPlanList(params)]).then((resolve, reject) => {
    console.log(resolve);

    const [res1, res2] = resolve;
    let header: any[] = [];
    let tableData: any = {};
    if (!res1.error) {
      header = [...res1.data];
    }

    if (!res2.error) {
      tableData = [...res2.data];
    }
    return Promise.resolve({ header, tableData });
  });
}

// 月计划产能新增
export function monthPlanCapacityTargetAdd(params: any) {
  return request({
    url: `/mes/plan/monthlyCapacityTarget/add/new`,
    method: 'post',
    data: params
  });
}
// 月计划产能编辑
export function monthPlanCapacityTargetEdit(params: any) {
  return request({
    url: `/mes/plan/monthlyCapacityTarget/update`,
    method: 'post',
    data: params
  });
}
// 月计划产能删除
export function monthPlanCapacityTargetDelete(params: any) {
  return request({
    url: `/mes/plan/monthlyCapacityTarget/deleteBatch`,
    method: 'post',
    data: params
  });
}

// 冲床生产报表添加尺寸校验--实际尺寸信息
export function actualSizeData(params: any) {
  return request({
    url: `qms/single/singlePunch/checkData`,
    method: 'get',
    params
  });
}
